<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return view('welcome');
});
Route::group(['namespace'=>'App','middleware'=>['auth','log.uri']],function () {

    Route::get('change_password', ['as' => 'change_password', 'uses' => 'SiteController@changePassword']);

    Route::post('change_password', ['as' => 'change_password_check', 'uses' => 'SiteController@changePasswordCheck']);

    Route::get('code', 'SiteController@code')->name('code');

    Route::group(['prefix' => 'index', 'as' => 'index.'], function () {
        Route::get('index', ['as' => 'index', 'uses' => 'IndexController@index']);
        Route::get('system', ['as' => 'system', 'uses' => 'IndexController@system']);
        Route::get('msn', ['as' => 'msn', 'uses' => 'IndexController@msn']);
        Route::get('memo', ['as' => 'memo', 'uses' => 'IndexController@memo']);
        Route::get('rule', ['as' => 'rule', 'uses' => 'IndexController@rule']);
        Route::get('parameter', ['as' => 'parameter', 'uses' => 'IndexController@parameter']);
        Route::get('car', ['as' => 'car', 'uses' => 'IndexController@car']);
        Route::get('attendence', ['as' => 'attendence', 'uses' => 'IndexController@attendence']);
    });

    Route::group(['prefix' => 'company', 'as' => 'company.'], function () {
        Route::get('show', ['as' => 'show', 'uses' => 'CompanyController@show']);
        Route::get('edit', ['as' => 'edit', 'uses' => 'CompanyController@edit']);
        Route::post('edit', ['as' => 'update', 'uses' => 'CompanyController@update']);
    });

    Route::group(['prefix'=>'permission','as'=>'permission.'],function(){
        Route::get('index/{role}', ['as' => 'index', 'uses' => 'PermissionController@index']);
        Route::get('show/{permission}', ['as' => 'show', 'uses' => 'PermissionController@show']);
        Route::get('assign/{role}', ['as' => 'assign', 'uses' => 'PermissionController@assign']);
        Route::post('assign/{role}', ['as' => 'assign_check', 'uses' => 'PermissionController@assignCheck']);
        Route::get('unassign/{role}/{permission}', ['as' => 'unassign', 'uses' => 'PermissionController@unassign']);
    });

    Route::resources([
        'user' => 'UserController',
        'depart'=> 'DepartController',
        'role'=>'RoleController',
    ]);

    Route::group(['namespace'=>'Ppe','prefix'=>'ppe','as'=>'ppe.'],function(){
        Route::resources([
           'ppe'=>'PpeController',
        ]);
    });
});


Auth::routes();

Route::get('/home', 'App\IndexController@index')->name('home')->middleware('auth');
